﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace SmartFront.Toolkit.Core
{
    /// <summary>
    /// The <see cref="CultureManager"/> class will provide <see cref="CultureInfo"/> 
    /// instances for intended purposes in the application.  This class makes it easy to 
    /// determine the correct culture to use in specific scenarios.
    /// </summary>
    /// <remarks>
    /// If you are using this class in a scenario which does not have a clear choice of which 
    /// <see cref="CultureInfo"/> to use, please ask someone.
    /// </remarks>
    public static class CultureManager
    {
        #region Fields

        /// <summary>
        /// The UserCulture should be used to format data for the user (Screen, Print, etc).
        /// </summary>
        public static readonly CultureInfo UserFormatCulture = CultureInfo.ReadOnly(CultureInfo.CurrentCulture);

		/// <summary>
        /// InternalCulture should be used for logging, and other internal diagnostic information.  
        /// </summary>
        public static readonly CultureInfo InternalCulture = CultureInfo.ReadOnly(CultureInfo.InvariantCulture);

        /// <summary>
        /// The Language culture should be used by Resource Manager for retrieving the culture specific resources at the run-time.
        /// </summary>
        public static readonly CultureInfo LanguageCulture = CultureInfo.ReadOnly(CultureInfo.CurrentUICulture);

        /// <summary>
        /// Gets the culture used by the databases.
        /// </summary>
        public static readonly CultureInfo DatabaseCulture = CultureInfo.ReadOnly(CultureInfo.InvariantCulture);

        /// <summary>
        /// Gets or sets the import/export encoding.
        /// </summary>
        /// <value>The import export encoding.</value>
        public static Encoding ImportExportEncoding { get; private set; }

        /// <summary>
        /// Gets the calendar to use for the user.
        /// </summary>
        /// <remarks>
        /// Application always returns US English <see cref="GregorianCalendar"/>.
        /// </remarks>
        /// <value>The calendar.</value>
        public static Calendar Calendar { get; private set; }

        /// <summary>
        /// The ImportExport culture should be used for exporting and importing data.  A consistent culture is important for data exports because importing and exporting in different cultures could change the meaning of some data.
        /// </summary>
        public static readonly CultureInfo ImportExportCulture = CultureInfo.InvariantCulture;

		#endregion

        #region Constructor

        /// <summary>
        /// Initializes the <see cref="CultureManager"/> class.
        /// </summary>
        static CultureManager()
        {
            Calendar = new GregorianCalendar(GregorianCalendarTypes.USEnglish);
            ImportExportEncoding = Encoding.Unicode;
        }

        #endregion
    }
}
